﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snake.Extensions
{
    public static class TypeExtensions
    {
        public static Type GetUnderlyingGenericType(this Type type)
        {
            if (!type.IsGenericType)
            {
                return type;
            }

            var genericType = type.GetGenericTypeDefinition();
            
            return genericType == typeof(Nullable<>) ? type.GetGenericArguments()[0] : type;
        }
    }
}
